package com.cxyd.common.utils;

import com.cxyd.common.exception.ErrorCode;
import com.cxyd.common.utils.entity.RequestData;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 其他系统调用[wcs-api]接收到的反馈信息
 */
@Data
public class ApiResult implements Serializable {
    private static final long serialVersionUID = 1L;
    @JsonProperty("Code")
    @JsonAlias("code")
    private String code;
    @JsonProperty("Message")
    @JsonAlias("msg")
    private String msg;
    private String requestPk = "404";
    @JsonProperty("Data")
    @JsonAlias("data")
    private RequestData data;

    public ApiResult success(String msg) {
        this.msg = msg;
        return this;
    }

    public ApiResult feedBack(String requestPk) {
        this.requestPk = requestPk;
        return this;
    }

    public ApiResult feedBack(String msg, String requestPk) {
        this.code = ErrorCode.API_SERVER_ERROR;
        this.msg = msg;
        this.requestPk = requestPk;
        return this;
    }
}
